package lanou3g.myfirstapp36kr.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

//import it.sephiroth.android.library.picasso.Picasso;
import com.squareup.picasso.Picasso;

import lanou3g.myfirstapp36kr.R;
import lanou3g.myfirstapp36kr.entity.FragmentMoneyViewPagerFragmentListViewEntity;

/**
 * Created by dllo on 16/8/5.
 */
public class FragmentFindListviewFirstAdapter extends BaseAdapter {
    private FragmentMoneyViewPagerFragmentListViewEntity entity;
    private Context context;

    public FragmentFindListviewFirstAdapter(Context context) {
        this.context = context;
    }

    public void setEntity(FragmentMoneyViewPagerFragmentListViewEntity entity) {
        this.entity = entity;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int i) {
        return entity.getData().getData().get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_fragmentfind_hotproject_listview,null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) view.getTag();
        }
        Picasso.with(context).load(entity.getData().getData().get(i).getCompany_logo()).into(viewHolder.imageViewlogal);
        viewHolder.textViewbelowdoor.setText(entity.getData().getData().get(i).getCompany_name());
        viewHolder.textViewsingmeet.setText(entity.getData().getData().get(i).getCompany_brief());
        viewHolder.textViewmakeperson.setText(entity.getData().getData().get(i).getLead_name());
        return view;
    }
    private class ViewHolder{
        private ImageView imageViewlogal;
        private TextView textViewbelowdoor;
        private TextView textViewsingmeet;
        private TextView textViewcreatperson;
        private TextView textViewmakeperson;
        public ViewHolder(View view) {
            imageViewlogal = (ImageView) view.findViewById(R.id.iv_item_fragmentfind_hotproject_listview_logal);
            textViewbelowdoor = (TextView) view.findViewById(R.id.tv_item_fragmentfind_hotproject_listview_);
            textViewsingmeet = (TextView) view.findViewById(R.id.tv_item_fragmentfind_hotproject_listview_singmeet);
            textViewcreatperson = (TextView) view.findViewById(R.id.tv_item_fragmentfind_hotproject_listview_creatperson);
            textViewmakeperson = (TextView) view.findViewById(R.id.tv_item_fragmentfind_hotproject_listview_makeperson);



        }
    }
}
